package com.bdqn.controller;

import com.bdqn.pojo.Menu;
import com.bdqn.service.MenuService;
import com.bdqn.util.TokenUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/menu")
@Tag(name = "菜单控制器",description = "菜单csgc")
public class MenuController {
    @Autowired
    TokenUtil tokenUtil;
    @Autowired
    MenuService menuService;
    /**
     * 获取用户所有的菜单权限
     */
    @GetMapping("getUserMenus")
    public List<Menu> getUserMenus(@RequestHeader("token") String token){
        int uid=tokenUtil.getUid(token);
        List<Menu> list=menuService.getUserMenus(uid);
        return list;
    }
    /**
     * 获取所有的菜单,按照层次关系返回
     */
    @GetMapping("getMenus")
    public List<Menu> getMenus(){
        List<Menu> list=menuService.getMenusAll();
        return list;
    }
}
